<template>
  <div>
    <section>
      <img class="full-width" src="/static/bg11.png" alt="">
    </section>
    <section class="section-2 relative">
      <p class="header mt60">TECHNOLOGICAL AWARD<span>科技创新奖</span></p>
      <div class="rules-item">
        <div class="mod flex-space-between" v-for="(item, index) in list" :key="index" @click="toDetail(item, index)">
          <div class="mod-left">
            <span class="circel"></span>
            <span class="title">{{item.title}}</span>
          </div>
          <!-- <div class="mod-right">
            <a  @click.stop="down(item.realPath)" class="down">下载</a>
            <span class="time">{{item.time}}</span>
          </div> -->
        </div>
      </div>
      <!-- <a-pagination class="xh-pager" :pageSize="pageSize" @change="changePage" v-model="current" :total="total" show-less-items /> -->
    </section>
  </div>
</template>
<script>
import { tracker } from 'lib/analytics'
export default {
  name: 'association',
  data () {
    return {
      list: [{
        title: '文件通知',
        path: ''
      }, {
        title: '申报系统',
        path: ''
      }, {
        title: '评选方法',
        path: ''
      }],
      current: 1,
      total: 0,
      hasToken: false,
      item: 0,
      pageSize: 10
    }
  },
  components: {
  },
  computed: {
  },
  created () {
    // this.getArticles()
    this.validToken()
  },
  methods: {
    getArticles () {
      this.$http.getArticles({}, 'KJCXJ', this.current, this.pageSize).then(res => {
        res.data.list.forEach(v => {
          v.realPath = `${process.env.VUE_APP_SRC}${v.realPath}`
        })
        this.total = res.data.total
        this.list = res.data.list
      })
    },
    validToken () {
      this.$http.validToken({}).then(res => {
        this.hasToken = res.data
        if (!res.data) {
          // this.$router.push({ path: '/login', query: { back: window.location.href } })
        }
      })
    },
    changePage (page, size) {
      this.current = page
      this.getArticles()
    },
    toDetail (item, index) {
      // this.$router.push({ path: `/fold/${item.id}` })
      if (this.item == 0) {
        if (index == 1) {
          this.item = 1
          this.list = [{
            title: '申报要求',
            path: ''
          }, {
            title: '填写申请',
            path: ''
          }, {
            title: '申请列表',
            path: ''
          }]
        } else if (index == 0) {
          this.$router.push({ path: '/innovation/create/file' })
        } else {
          this.$router.push({ path: '/innovation/create/way' })
        }
      } else {
        if (index == 1) {
          if (!tracker.getRoles() || !tracker.getRoles().includes("3")) {
            this.$router.push({ path: '/login', query: { back: window.location.href, role: 3 } })
            return false
          }
          if (!this.hasToken) {
            this.$router.push({ path: '/login', query: { back: window.location.href, role: 3 } })
          } else {
            this.$router.push({ path: '/innovation/create/1' })
          }
        } else if (index == 2) {
          this.$router.push({ path: '/innovation/list' })
        }
      }
    },
    down (url) {
      if (url) {
        window.location.href = url
      }
    }
  }
}
</script>
<style lang="scss">
</style>
